package com.xingdata.jjxc.map.navi.callback;

import java.util.ArrayList;
import java.util.List;

/**
*    
* 项目名称：JJXC_VPN   
* 类名称：CommunicationUpdata   
* 类描述：   自定义蓝牙观察者
* 创建人：JiangMin 
* 创建时间：2015-5-13 上午10:03:56    
* 修改备注：   
* @version    
*
 */
public class BluetoothUpdataObserver {
	static Object object = new Object();
	static BluetoothUpdataObserver updata;
	List<BluetoothCommunicationInterface> bluetoothCommunicationInterfaces = new ArrayList<BluetoothCommunicationInterface>();

	public void setCommunicationInterface(BluetoothCommunicationInterface mInterface){
		if(mInterface==null)
			return;
		if (!bluetoothCommunicationInterfaces.contains(mInterface)) 
			bluetoothCommunicationInterfaces.add(mInterface);
	}
	
	
	public static BluetoothUpdataObserver getCommunicationUpdata(){
		if(updata == null){
			synchronized (object) {
				if(updata == null){
					updata = new BluetoothUpdataObserver();
				}
			}
		}
		return updata;
	}
	
	public void CommunicationUpdata(int mark) {
		for(int i = 0; i < bluetoothCommunicationInterfaces.size(); i++){
			//这里用来通知上传图片操作
			bluetoothCommunicationInterfaces.get(i).startCommunication(mark);
		}
	}
	


	public void clearUpdateCommunicationUpdata() {
		if (bluetoothCommunicationInterfaces == null)
			bluetoothCommunicationInterfaces.clear();
	}
}
